page.tsx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React, { useEffect } from 'react'
  4. import cn from 'classnames'
  5. import type { IMainProps } from '@/app/components/share/chat'
  6. import EmbeddedChatbot from '@/app/components/base/chat/embedded-chatbot'
  7. import Loading from '@/app/components/base/loading'
  8. import { fetchSystemFeatures } from '@/service/share'
  9. import LogoSite from '@/app/components/base/logo/logo-site'
  10. const Chatbot: FC<IMainProps> = () => {
  11. const [isSSOEnforced, setIsSSOEnforced] = React.useState(true)
  12. const [loading, setLoading] = React.useState(true)
  13. useEffect(() => {
  14. fetchSystemFeatures().then((res) => {
  15. setIsSSOEnforced(res.sso_enforced_for_web)
  16. setLoading(false)
  17. })
  18. }, [])
  19. return (
  20. <>
  21. {
  22. loading
  23. ? (
  24. <div className="flex items-center justify-center h-full" >
  25. <div className={
  26. cn(
  27. 'flex flex-col items-center w-full grow items-center justify-center',
  28. 'px-6',
  29. 'md:px-[108px]',
  30. )
  31. }>
  32. <Loading type='area' />
  33. </div>
  34. </div >
  35. )
  36. : (
  37. <>
  38. {isSSOEnforced
  39. ? (
  40. <div className={cn(
  41. 'flex w-full min-h-screen',
  42. 'sm:p-4 lg:p-8',
  43. 'gap-x-20',
  44. 'justify-center lg:justify-start',
  45. )}>
  46. <div className={
  47. cn(
  48. 'flex w-full flex-col bg-white shadow rounded-2xl shrink-0',
  49. 'space-between',
  50. )
  51. }>
  52. <div className='flex items-center justify-between p-6 w-full'>
  53. <LogoSite />
  54. </div>
  55. <div className={
  56. cn(
  57. 'flex flex-col items-center w-full grow items-center justify-center',
  58. 'px-6',
  59. 'md:px-[108px]',
  60. )
  61. }>
  62. <div className='flex flex-col md:w-[400px]'>
  63. <div className="w-full mx-auto">
  64. <h2 className="text-[16px] font-bold text-gray-900">
  65. Warning: Chatbot is not available
  66. </h2>
  67. <p className="text-[16px] text-gray-600 mt-2">
  68. Because SSO is enforced. Please contact your administrator.
  69. </p>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. )
  76. : <EmbeddedChatbot />
  77. }
  78. </>
  79. )}
  80. </>
  81. )
  82. }
  83. export default React.memo(Chatbot)